<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

<style type="text/css">
.but {
	width:350px;
	margin: auto;
    margin-top: 25px;
}

.but input{
	width:80px;
	height:30px;
}
.but #can{
	margin-left: 15px;
}
.content{
	font-size: 20px;
}
#infcon{
	font-size:14px;
	margin-top: 25px;
	margin-left: 50px;
}
.con{
	margin-top: 25px;
}
.inf{
	margin-left: 50px;
}

</style>
<link rel="stylesheet" type="text/css"
	href="${initParam.url }/statics/css/demo.css">
<link rel="stylesheet" type="text/css"
	href="${initParam.url }/statics/css/easyui.css">
<script type="text/javascript"
	src="${initParam.url }/statics/js/jquery.min.js"></script>

<script type="text/javascript"
	src="${initParam.url }/statics/js/jquery.easyui.min.js"></script>
<script type="text/javascript">
var s = ",";//设定分隔付
	$(function() {
		
		$('#cc').combo({

			required : true,//是否验证

			editable : true,//是否可编辑

			multiple : true
		//可否支持多选

		});

		$("#sp").appendTo($('#cc').combo("panel"));
		
		$(".la").click(function oi(){
			
			
			var v = $(this).next('span').text();

			if ("," == s || "" == s) {//第一次勾选时起作用

				s = $(this).next('span').text();

			}

			else if (-1 < s.indexOf(v)) {//当去掉勾选时起作用  Indexof:返回某个指定的字符串值在字符串中首次出现的位置

				var n = s.indexOf(v);

				var m = s.indexOf(v) + v.length;

				if (0 == s.indexOf(v)) {//取消第一个点击的勾选

					s = s.substring(n + v.length + 1, s.length);

				} else if (0 < s.indexOf(v)
						&& ((s.indexOf(v) + v.length) < s.length)) {//取消非第一个和最后一个的勾选

					s = s.substring(0, n)
							+ s.substring(n + v.length + 1, s.length);

				} else {//取消最后一个的勾选

					s = s.substring(0, n - 1);

				}

			}

			else {

				s = s + "," + $(this).next('span').text();//将勾选各值拼接

			}

			$('#cc').combo('setValue', s).combo('setText', s).combo(
					'showPanel');//将值赋值给文本框并在文本里显示出来	
		})			
	});
	
	
	
	var flag = 1;
	function ou() {
		var radi = $('input:radio:checked').val();
		var text = $('#text').val();
		var checked = [];
		if(text!=null && text!=""){
			return true;
		}else{
			$("#error").html("请输入要发送的内容！")
			return false;
		}
		flag = 0;
		$('input:checkbox:checked').each(function() {
			checked.push($(this).val());
			
		});
		$.ajax({
			type : "post",
			url : "/property/main/in",
			cache : false,
			traditional : true,
			data : {
				'checked' : checked,
				'radio' : radi,
				"text" : text
			},
			success : function(msg) {
				window.location.href='/property/main/informlist';
			},
			error : function() {
				
				$('#cc').combo('setValue', "").combo('setText', "房屋编号不能为空").combo(
				'showPanel');
			
				return false;
			}
		})
		
		alert(text);
		
	};

	//全选房屋
	function qx(){
		
		//var ch=[];
		//$("input[name='lang']").attr("checked","checked");
		
            $("input:checkbox").each(function () {
                $(this).prop("checked", true);
            });
            
		 
		s=",";
		flag = 0;
		
		
		$('input:checkbox:checked').each(function() {
			//checked.push($(this).val());
				if ("," == s || "" == s) {//第一次勾选时起作用
					s=$(this).next('span').text();
					
				}else{
					s=s+","+$(this).next('span').text();
				}
				
		});
	
		$('#cc').combo('setValue', s).combo('setText',s).combo(
		'showPanel');//将值赋值给文本框并在文本里显示出来
        //$("#cc").text(ch);
		//alert($("#cc").text(ch))
		
	}
	//清空房屋
	function bx(){
		$("input[name='lang']").attr("checked",null);
		s=",";
		$('#cc').combo('setValue', "").combo('setText',"").combo(
		'showPanel');//将值赋值给文本框并在文本里显示出来
		
	}
	$("form").submit(function() {
		
		
		ou();
	})
</script>
</head>
<body>
	<div
		style="width: 1050px; height: 620px; background-color: #FFF; margin: 20px;">
		<h4
			style="background-color: #9FB2C2; padding-left: 10px; color: #516D8A; line-height: 40px;">
			<img alt="" src="${initParam.url}/statics/images/title.jpg">编辑通知
		</h4>
		<form action="" method="post">
			<div style="margin: 30px; padding: 20px;">
				<h3>请填写要发送的信息:</h3>
				<div id="infcon">
				<div class="centent">
					<label>房屋编号：</label> <select id="cc" class="col-sm-4 form-control easyui-combobox "  data-options="multiple:true,multiline:true" style="width: 200px;"></select>

					<div id="sp">

						<div style="color: #99BBE8; background: #fafafa; padding: 5px;">请选择渠道</div>
						<input type="button" onclick="qx();" value="全选" >
						<input type="button" onclick="bx();" value="清空">
						<div id="abc">
						<c:forEach var="li" items="${list}">
							<div style="padding: 5px">

								<input type="checkbox" onclick="xk();" class="la"  name="lang" value="${li.id }" /><span>${li.tower }</span><br />

							</div>
						</c:forEach>
						</div>
					</div>
					<span class="inf">
					<label>通知类型：</label> <input type="radio" name="type"
						value="缴费通知">缴费通知 <input type="radio" name="type"
						checked="checked" value="通知公告">公告通知
						</span>
				</div>
				<div class="con">
					<label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;文本：</label>
					<textarea id="text" class="form-control" style="width: 500px; height: 280px;display: inline;"
						name="content"></textarea>
				</div>
				<div class="but">
					<input type="button" onclick="ou();" value="确定"> <input type="button"
						id="can" value="取消" onclick="javascript:history.back(-1);">
						<span id="error" style="color:red"></span>
				</div>
				
			</div>
			</div>
		</form>
	</div>
</body>
</html>